package com.meta.services
{
	import flash.net.SharedObject;

	public class SOService
	{
		public function SOService()
		{
		}

		private static var so:SharedObject;
		public static const APPNAME:String = "meta-classroom";

		public static function SO():SharedObject
		{
			if (!so)
				so=SharedObject.getLocal(APPNAME);
			return so;
		}

		public static function getValue(key:String):*
		{
			return SO().data[key];
		}

		public static function setValue(key:String, value:Object):void
		{
			SO().data[key]=value;
			SO().flush();
		}

		public static function Log(obj:Object):void
		{
			var arr:Array = getValue("log");
			if(!arr)
				arr = [];
			arr.push(obj);
			if(arr.length>100)
				arr.shift();
			setValue("log",arr)
		}

		public static function sendLog():void
		{
			var arr:Array = getValue("log");
			if(arr&&arr.length)
			{
				var str:String = JSON.stringify(arr);
//				trace(str)
//				API.instance.sendLog(str);
			}
		}
	}
}


